package com.bungarus.client.busi;

import com.bungarus.codec.protobuf.MessageProtobuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * Created by tang on 2018/11/11.
 */
public class ClientHandler extends ChannelInboundHandlerAdapter {
    public static String sessionID;
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        MessageProtobuf.Message message = (MessageProtobuf.Message)msg;
        MessageProtobuf.Header header = message.getHeader();
        MessageProtobuf.Body body = message.getBody();

        if(null != header){
            sessionID=header.getSessionId();
            System.out.println("+++++++++++++ sessionID from server: " + header.getSessionId());
            System.out.println("+++++++++++++ token from server: " + header.getToken());
        }

        System.out.println("=========== recv: " + msg.toString());
        super.channelRead(ctx, msg);
    }
}
